home *** CD-ROM | disk | FTP | other *** search
/ PCNet 1998 May / PCnet Mayıs 1998.iso / Internet / Browsers / amaya-Windows95-1.2.ZIP / thot / amaya / HTML.trans < prev    next >
Encoding:
Text File  |  1998-01-08  |  9.0 KB  |  428 lines

  1. ! Use of the file HTML.trans
  2. !!!!!!!!!!!!!!!!!!!!!!!!!!!!
  3. ! This file can be edited during an Amaya session. It will be 
  4. ! dynamically parsed when the transformation tool is required by
  5. ! the editor. So new transformations can be added while editing.
  6. !
  7. ! Syntax of the transformation language for Amaya
  8. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  9. !
  10. ! comments begin with !
  11. !
  12. ! This file can be edited during an Amaya session. It will be 
  13. ! dynamically parsed when the transformation tool is required by
  14. ! the editor. So new transformations can be added while editing.
  15. !
  16. ! A tranformation rule has three parts : 
  17. !     - a name terminated by a colon ":"
  18. !     - a source pattern terminated by a semi-colon ";"
  19. !     - and a list of rules between braces "{" "}", each one
  20. !           terminated by a semi-colon ";"
  21. !
  22. ! The name will appear in the transform menu.
  23. !
  24. ! The pattern gives of a specific organization of the elements
  25. ! to be transformed: it contains HTML tags and SGML-like syntax
  26. ! for the composition operators:
  27. !     e1 | e2   for a choice between elements e1 and e2
  28. !     e1 , e2   for a sequence e1 followed by e2
  29. !     e+        for a sequence of one or more elements e
  30. !     ?e        for an optional element e
  31. !     ( )       for grouping nodes
  32. ! The braces "{" "}" define the content of a node.
  33. ! The symbol "*" is a token that matches any element type
  34. ! It is possible to rename a tag by preceeding it with a name
  35. ! followed by a colon ":"
  36. !
  37. ! A rule expresses transformations to be applied to the elements 
  38. ! identified in the pattern. They have two parts :
  39. !        - a source identifier: a tag or a name which occurs in
  40. !          the pattern and links the rule to the pattern nodes
  41. !        -  a rule body: drives the transformation
  42. !  Each rule end with a symbol ";"
  43. !
  44. ! there are two kinds of rule bodies:
  45. ! - A discard rule body is slash and express that the correspoding
  46. !    pattern node does not occurin the transformation result
  47. !
  48. ! - A generation rule begins with
  49. !     - a symbol ">"
  50. !     - and a target tag list. This list is itself divided into
  51. !       two parts separated by a colon":": 
  52. !         * the generation location path
  53. !         * and the list of tags to be generated
  54. ! The dot symbol "." is used for descending in the tree structure.
  55. ! if the special token star "*" ends the list of tags to be 
  56. ! generated, the source elment tag is not changed but this element
  57. ! can be moved in a different place in the destination. 
  58. !
  59. ! The rules are applied in the order the identifeiers are met when
  60. ! (depth first) traversing the source structure.
  61. ! Several rules may have the same identifier, in that case, the rules
  62. ! are applied in the order they are defined.
  63.  
  64. ! Transformation rules 
  65. !!!!!!!!!!!!!!!!!!!!!!
  66.  
  67. Address:(P{*+})+;
  68.     {
  69.     * > ADDRESS:*;
  70.     }
  71.  
  72. !between lists
  73. !!!!!!!!!!!!!!
  74.  
  75. Definition list:*{(LI{(P|list:*{(li2:LI)+})+})+};
  76.     {
  77.     P > DL:DT;
  78.     list > DL:DD;
  79.     li2 > DL.DD:;
  80.     }
  81.  
  82. Bulleted list:(DL{(DT|DD{(*)+})+})+;
  83.     {
  84.     DT > UL:LI;
  85.     * > UL.LI.UL:LI.*;
  86.     }
  87.  
  88. Numbered list:(DL{(DT|DD{(*)+})+})+;
  89.     {
  90.     DT > OL:LI;
  91.     * > OL.LI.OL:LI.*;
  92.     }
  93.  
  94. Remove DL: (DL{(DT|DD{*+})+})+;
  95.     {
  96.      DT > :P;
  97.      * > :*;
  98.     }
  99.  
  100. !flattering headings 
  101. !!!!!!!!!!!!!!!!!!!!
  102.  
  103. Paragraphs: 
  104. (H1|H2|H3|H4|H5|H6|*{(LI{(il:*)+})+}),(H1|H2|H3|H4|H5|H6|P|*{(LI{(il:*)+})+})+;
  105.     { 
  106.     H1 > :P;
  107.     H2 > :P;
  108.     H3 > :P;
  109.     H4 > :P;
  110.     H5 > :P;
  111.     H6 > :P;
  112.     P > :P;
  113.     il > :P;
  114.     }
  115.  
  116. ! Preformatted to/from paragraphs
  117. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  118.  
  119. Preformatted: P+;
  120.     {
  121.     P>:PRE;
  122.     }
  123.  
  124. Paragraph: PRE+;
  125.     {
  126.     PRE>:P;
  127.     }
  128.  
  129.  
  130.  
  131.  
  132. !Tables to/from lists
  133. !!!!!!!!!!!!!!!!!!!!
  134.  
  135. Table: *{(lev1:LI{?(*{(lev2:LI)+}|elem:*)+})+};
  136.     {
  137.     lev1 > <TABLE border=1>:TR;
  138.     elem > TABLE.TR:TD.*;
  139.     lev2 > TABLE.TR:TD;
  140.     }
  141.  
  142. Table: DL{(DT|DD)+};
  143.     {
  144.     DT > <TABLE border=1>.TBODY:TR.TD;
  145.     DD > TABLE.TBODY.TR:TD;
  146.     }
  147.  
  148. Numbered List:TABLE{?CAPTION,(block:*{(TR{(TD|TH),?(TD2:TD|TH2:TH)+})+})+};
  149.       {
  150.     CAPTION > :P.STRONG;
  151.     block > :OL;
  152.     TR > OL:LI;
  153.     TD > OL.LI:;
  154.     TH > OL.LI:;
  155.     TD2 >OL.LI.UL:LI;
  156.     TH2 >OL.LI.UL:LI;
  157.     }
  158.  
  159. Bulleted List:TABLE{?CAPTION,(block:*{(TR{(TD|TH),?(TD2:TD|TH2:TH)+})+})+};
  160.     {
  161.     CAPTION > :P.STRONG;
  162.     block > :UL;
  163.     TR > UL:LI;
  164.     TD > UL.LI:;
  165.     TH > UL.LI:;
  166.     TD2 >UL.LI.UL:LI;
  167.     TH2 >UL.LI.UL:LI;
  168.     }
  169.  
  170. ! List transformations
  171. !!!!!!!!!!!!!!!!!!!!!!
  172.  
  173. Remove one level: *{(LI{(cont:*)+})+};
  174.     {
  175.     cont > :*;
  176.     }
  177.  
  178. Remove two levels: *{(LI{(*{?(LI{(Lev2:*)+})+})+})+};
  179.     {
  180.     Lev2 > :*;
  181.     }
  182.  
  183. Merge Items: LI,(LI2:LI)+;
  184.     {
  185.     LI > LI:;
  186.     LI2 > LI:;
  187.     }
  188.  
  189. Split Items: (LI{a:*,(b:*)+})+;
  190.     {
  191.     a > :LI.*;
  192.     b > :LI.*;
  193.     }
  194.  
  195. Merge Lists: UL{LI+},(UL{LI+})+;
  196.     {
  197.     LI > UL:LI;
  198.     }
  199.  
  200. Merge Lists: OL{LI+},(OL{LI+})+;
  201.     {
  202.     LI > OL:LI;
  203.     }
  204.  
  205. Merge Lists: DL{(DT|DD)+},(DL{(DT|DD)+})+;
  206.     {
  207.     DT > DL:DT;
  208.     DD > DL:DD;
  209.     }
  210.  
  211. ! Forms to/from elements
  212. !!!!!!!!!!!!!!!!!!!!!!!!
  213.  
  214. Form: *+;
  215.     {
  216.     *>Form:*;
  217.     }
  218.  
  219. Remove Form: FORM{*+};
  220.     {
  221.     *>:*;
  222.     }
  223.  
  224. ! Lists to/from elements
  225. !!!!!!!!!!!!!!!!!!!!!!!!
  226.  
  227. Bulleted list: (P|OL|MENU|DIR|PRE|FORM)+;
  228.        {
  229.         P > UL:LI;
  230.         OL> UL;
  231.         MENU> UL:LI.MENU;
  232.         DIR> UL:LI.DIR;
  233.         PRE> UL:LI.PRE;
  234.         FORM> UL:LI.FORM;
  235.         }
  236.  
  237. Numbered list:(P|UL|MENU|DIR|PRE|FORM)+;
  238.        {
  239.         P > OL:LI;
  240.         UL> OL;
  241.         MENU> OL:LI.MENU;
  242.         DIR> OL:LI.DIR;
  243.         PRE> OL:LI.PRE;
  244.         FORM> OL:LI.FORM;
  245.         }
  246.  
  247. ! Tables to/from elements
  248. !!!!!!!!!!!!!!!!!!!!!!!!!
  249.  
  250. !Table: (H:H1|H:H2|H:H3|H:H4|H:H5|H:H6|P),(H:H1|H:H2|H:H3|H:H4|H:H5|H:H6|*)+;
  251. !    {
  252. !    P> <TABLE border=1>.TR.TD:P;
  253. !    H> <TABLE border=1>:TR.TD.*;
  254. !    *> <TABLE border=1>.TR:TD.*;
  255. !    }
  256.  
  257.  
  258. Vertical Table: *,*+;
  259.     {
  260.     *><TABLE border=1>:TR.TD.*;
  261.     }
  262.  
  263. Horizontal Table : *,*+;
  264.     {
  265.     *><TABLE border=1>.TR:TD.*;
  266.     }
  267.  
  268. Remove Table:TABLE{?CAPTION,?(body:*{(TR{(*{(?cell_content:*)+})+})+})+};
  269.     {
  270.     CAPTION>H3;
  271.     cell_content>:*;
  272.     }
  273.  
  274. Transpose Table:TABLE{TBODY{TR{(TD|TH)+}|(TR{td2:TD|th2:TH})+}};
  275.     {
  276.     TD><TABLE BORDER=TABLE.BORDER>:TR.TD;
  277.     TH>TABLE:TR.TD;
  278.     td2><TABLE BORDER=TABLE.BORDER>.TR:TD;
  279.     th2>TABLE.TR:TD;
  280.     }
  281.  
  282. Heading Cell :?(TD|TH)+,TD,?(TD|TH)+;
  283.     {
  284.     TD>:TH;
  285.     }
  286.  
  287. Data Cell :?(TD|TH)+,TH,?(TD|TH)+;
  288.     {
  289.     TH>:TD;
  290.     }
  291.  
  292. !headings to/from definitions
  293. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  294.  
  295. Definition list:((H1|H2|H3|H4|H5|H6),*+)+;
  296.     {
  297.     H1 > DL:DT;
  298.     H2 > DL:DT;
  299.     H2 > DL:DT;
  300.     H3 > DL:DT;
  301.     H4 > DL:DT;
  302.     H5 > DL:DT;
  303.     H6 > DL:DT;
  304.     * > DL.DD:*;
  305.     }
  306.  
  307.  
  308. Definition list:(H1,?HR,?(level1:*)+,?(H2,?(level2:*)+,?((H3|H4|H5|H6),(level3:*)+)+)+)+;
  309.     {
  310.     H1 > DL:DT;
  311.     level1>DL.DD:*;
  312.     H2 > DL.DD:DL.DT ;
  313.     level2 > DL.DD.DL.DD:*;
  314.     H3 > DL.DD.DL.DD:DL.DT ;
  315.     H4 > DL.DD.DL.DD:DL.DT ;
  316.     H5 > DL.DD.DL.DD:DL.DT ;
  317.     H6 > DL.DD.DL.DD:DL.DT ;
  318.     level3 > DL.DD.DL.DD.DL.DD:*;
  319.     }
  320.  
  321. Definition list:(H2,?HR,?(level1:*)+,(H3,?(level2:*)+,((H4|H5|H6),(level3:*)+)+)+)+;
  322.     {
  323.     H2 > DL:DT;
  324.     level1>DL.DD:*;
  325.     H3 > DL.DD:DL.DT ;
  326.     level2 > DL.DD.DL.DD:*;
  327.     H4 > DL.DD.DL.DD:DL.DT ;
  328.     H5 > DL.DD.DL.DD:DL.DT ;
  329.     H6 > DL.DD.DL.DD:DL.DT ;
  330.     level3 > DL.DD.DL.DD.DL.DD:*;
  331.     }
  332.  
  333.  
  334.  
  335. Definition list:(H3,?HR,?(level1:*)+,?(H4,?(level2:*)+,((H5|H6),(level3:*)+)+)+)+;
  336.     {
  337.     H3 > DL:DT;
  338.     level1>DL.DD:*;
  339.     H4 > DL.DD:DL.DT ;
  340.     level2 > DL.DD.DL.DD:*;
  341.     H5 > DL.DD.DL.DD:DL.DT ;
  342.     H6 > DL.DD.DL.DD:DL.DT ;
  343.     level3 > DL.DD.DL.DD.DL.DD:*;
  344.     }
  345.  
  346. Multi level Definition list:(H4,?HR,?(level1:*)+,(H5,?(level2:*)+,((H6)+,(level3:*)+)+)+)+;
  347.     {
  348.     H4 > DL:DT;
  349.     level1>DL.DD:*;
  350.     H5 > DL.DD:DL.DT ;
  351.     level2 > DL.DD.DL.DD:*;
  352.     H6 > DL.DD.DL.DD:DL.DT ;
  353.     level3 > DL.DD.DL.DD.DL.DD:*;
  354.     }
  355.  
  356.  
  357.  
  358. Headings H1:(DL{(dt1:DT|DD{(DL{(dt2:DT|DD{(DL{(dt3:DT|DD{content:*})+}|content:*)+})+}|content:*)+})+}|HR)+;
  359.     {
  360.     dt1 > :H1;
  361.     dt2 > :H2;
  362.     dt3 > :H3;
  363.     content > :*;
  364.     }
  365.  
  366. Headings H2:(DL{(dt1:DT|DD{(DL{(dt2:DT|DD{(DL{(dt3:DT|DD{content:*})+}|content:*)+})+}|content:*)+})+}|HR)+;
  367.     {
  368.     dt1 > :H2;
  369.     dt2 > :H3;
  370.     dt3 > :H4;
  371.     content > :*;
  372.     }
  373.  
  374.  
  375. Headings H3:(DL{(dt1:DT|DD{(DL{(dt2:DT|DD{(DL{(dt3:DT|DD{content:*})+}|content:*)+})+}|content:*)+})+}|HR)+;
  376.     {
  377.     dt1 > :H3;
  378.     dt2 > :H4;
  379.     dt3 > :H5;
  380.     content > :*;
  381.     }
  382.  
  383. Definition list: P,*+;
  384.     {
  385.     P > DL:DT;
  386.     * > DL.DD:*;
  387.     }
  388.  
  389. Remove Div: (DIV{*+})+;
  390.     {
  391.         * > :*;
  392.     }
  393.  
  394. Remove P level: P{IMG};
  395.     {
  396.         IMG > :*;
  397.     }
  398.  
  399. Remove BlockQuote: (BLOCKQUOTE{*+})+;
  400.     {
  401.     * > :*;
  402.     }
  403.  
  404. Remove tag FONT: FONT{*+};
  405.     {
  406.     * > :*;
  407.     }
  408.  
  409. Remove SPAN: SPAN{*+};
  410.     {
  411.     *>:*;
  412.     }
  413.     
  414. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  415. ! Global Document transformation tests !
  416. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  417.  
  418. DistrThot: BODY{*+}
  419.     {
  420.     BODY >     <TABLE border=0 with="100%">.TBODY.TR.<TD with="30%">.<A href="http://opera.inrialpes.fr/OPERA/Thot.en.html"><IMG src="thot.gif" alt="Thot Editor" border=0 align="middle">;
  421.     BODY > TABLE.TBODY.TR.TD:<A href = "http://opera.inrialpes.fr">.<IMG src="opera.gif" alt="Opera project" border=0 align="middle">;
  422.     BODY > TABLE.TBODY.TR:TD.<IMG src="guide.gif" alt="Documentation" border=0 align="middle">;
  423.     BODY > TABLE.TBODY.TR.TD:H1."Title of the page";
  424.     BODY > :<TABLE border=0 with="100%">.TBODY.TR.<TD with="30%">.H2.<A href="Index.html">."Home";
  425.     * > TABLE.TBODY.TR:TD.*;
  426.     }
  427.  
  428.